package com.huluobo.a2308douyindemo.shop

import android.util.Log
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.huluobo.a2308douyindemo.adapter.GoodsCommentAdapter
import com.huluobo.a2308douyindemo.databinding.FragmentCommentBinding
import com.huluobo.a2308douyindemo.mvvm.BaseFragment

class CommentFragment : BaseFragment<FragmentCommentBinding, ShopViewModel>() {
    private lateinit var goodsCommentAdapter: GoodsCommentAdapter
    override fun initData() {
        vm.getGoodsComment()
        vm.getGoodsCommentSuccess.observe(this) {
            goodsCommentAdapter.data.clear()
            goodsCommentAdapter.data.addAll(it.data)
            goodsCommentAdapter.notifyDataSetChanged()
        }
    }

    override fun initView() {
        binding.detailCommentRv.layoutManager = LinearLayoutManager(requireContext())
        goodsCommentAdapter = GoodsCommentAdapter()
        binding.detailCommentRv.adapter = goodsCommentAdapter
    }
}